package com.yidu.drug.action;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yidu.drug.common.Page;
import com.yidu.drug.common.Tools;
import com.yidu.drug.dao.PurchaseOrderModelMapper;
import com.yidu.drug.dao.RepertoryModelMapper;
import com.yidu.drug.model.QtSumModel;
import com.yidu.drug.model.QualityTestingModel;
import com.yidu.drug.model.RepertoryModel;
import com.yidu.drug.service.QtSumModelService;

@Controller
@RequestMapping("/qtSumModel")
public class QtSumModelAction {
	@Resource
	private QtSumModelService qtSumModelService;
	
	@Resource
	private PurchaseOrderModelMapper purchaseOrderModelDao;
	
	@Resource
	private RepertoryModelMapper repertoryDao;
	
	
	/**
	 * 查询所有数据
	 * @throws UnsupportedEncodingException 
	 */
	@RequestMapping("/findAllQtSumModel")
	@ResponseBody
	public Map<String, Object> findAllQtSumModel(HttpServletRequest request,HttpServletResponse response,String sumRemark,String page,String limit) throws UnsupportedEncodingException{
		System.out.println("进来了=-=-=-=--=");
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");


		System.out.println(sumRemark+"---------------------");

		Page pages = new Page();
		pages.setPage(Integer.valueOf(page));
		pages.setRows(Integer.valueOf(limit));
		
		

		QtSumModel qtSumModel = new QtSumModel();
		qtSumModel.setPage(pages);
		qtSumModel.setSumRemark(sumRemark);
		
	
		
		List<QtSumModel> list = qtSumModelService.findAllQtSumModel(qtSumModel);
		for(QtSumModel QtSumModel:list){
			System.out.println(QtSumModel.getSumRemark()+"========================");
		}
		System.out.println("到了这一步=-=-=-=-=-=-=-");
		Long count = qtSumModelService.findRows(qtSumModel);
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("code", 0);
		map.put("msg", "");
		map.put("count", count);
		map.put("data", list);
		System.out.println("多撒us户的撒肯定撒");
		if(!Tools.isEmpty(list)){
			return map;
		}
		return null;
		
	}
	/**
	 * 增加管理人员数据
	 * @return 
	 * @return
	 */
	@RequestMapping("/addQtSumModel")
	public int add(QtSumModel qtSumModel,HttpSession session) throws IOException{
		return qtSumModelService.save(qtSumModel);
		
	}
	
	
}
